package cn.com.api.service.impl;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.api.entity.ApiT_token;
import cn.com.api.mapper.ApiT_tokenMapper;
import cn.com.api.service.ApiT_tokenService;
import cn.com.api.service.impl.base.T_tokenServiceImplBase;
import cn.com.util.DateUtil;
import cn.com.util.*;

/**
 * 
 **/
@Service
public class ApiT_tokenServiceImpl extends T_tokenServiceImplBase implements
		ApiT_tokenService {
	@Autowired
	private ApiT_tokenMapper apiT_tokenMapper;

	/**
	 * 配送端实时更新地址 经纬度
	 */
	@Transactional
	@Override
	public void updateSendAddress(Map<String, String> params,
			Map<String, Object> map) {
		String u_id = params.get("u_id");
		String token = params.get("token");
		String longitude = params.get("longitude");
		String latitude = params.get("latitude");
		// 根据u_id 和 token 查询token表
		ApiT_token apiTtoken = apiT_tokenMapper.selectApiT_tokenByUidAndRole(
				Integer.valueOf(u_id), 3);
		if (apiTtoken != null) {
			apiTtoken.setLongitude(longitude);
			apiTtoken.setLatitude(latitude);
			apiTtoken.setOperatedate(DateUtil.nowTimeToString());
			apiT_tokenMapper.updateT_token(apiTtoken);
		}
		map.put(Utils.RESULT, Utils.RESULT_RC_SUCCESS);
		map.put(Utils.MESSAGE, "success");
	}

}
